package org.hy.common.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author hy
 * @version 1.0
 * @date 2020-09-17 16:38
 */
public final class DateUtils {

    private DateUtils(){
        throw new AssertionError("no instance for you.");
    }

    private static final DateFormat dateFormat = new SimpleDateFormat("yyy-MM-dd");

    public static String todayStr(){
        return dayToStr(new Date());
    }

    public static String dayToStr(Date date){
        return dateFormat.format(date);
    }

    public static String todayStr(String pattern){
        return dayToStr(new Date(), pattern);
    }

    public static String dayToStr(Date date, String pattern){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        return simpleDateFormat.format(date);
    }
}
